package face.pay.web.oem.controller;

import face.pay.entity.SmsConfig;
import face.pay.entity.UserInfo;
import face.pay.security.annotation.CurrentUser;
import face.pay.security.exception.BaseException;
import face.pay.util.ResultMessage;
import face.pay.util.page.PageData;
import face.pay.util.page.PageParam;
import face.pay.web.oem.service.IOemSmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/sms")
public class OemSmsConfigController {


    @Autowired
    private IOemSmsService iOemSmsService;


    /**
     * 查看短信配置信息
     *
     * @return
     */
    @RequestMapping("/list")
    public String manager() {
        return "oem/oem_sms_info";
    }


    /**
     * 分页查询当前oem商下的短信模板
     * @param loginUser
     * @param pageParam
     * @return
     * @throws BaseException
     */
    @RequestMapping("/queryData")
    @ResponseBody
    public PageData data(@CurrentUser UserInfo loginUser, SmsConfig smsConfig, PageParam pageParam) throws BaseException {
        smsConfig.setOemId(loginUser.getOemId());
        return this.iOemSmsService.queryPage(smsConfig, pageParam);
    }


    /**
     * 编辑商家支付资料
     * @param
     * @return
     * @throws BaseException
     */
    @RequestMapping("/edit")
    @ResponseBody
    public ResultMessage editMchPayInfo(@CurrentUser UserInfo loginuser,  SmsConfig smsConfig) throws BaseException {
        smsConfig.setUpdatedBy(loginuser.getId());
        smsConfig.setOemId(loginuser.getOemId());
        return  this.iOemSmsService.editSmsInfo(smsConfig);

    }

}
